this.BX=this.BX||{};(function(e,t){"use strict";function r(e,t){return t={exports:{}},e(t,t.exports),t.exports}var i=r((function(e){(function(t){var r=t.HTMLCanvasElement&&t.HTMLCanvasElement.prototype;var i=t.Blob&&function(){try{return Boolean(new Blob)}catch(e){return false}}();var a=i&&t.Uint8Array&&function(){try{return new Blob([new Uint8Array(100)]).size===100}catch(e){return false}}();var n=t.BlobBuilder||t.WebKitBlobBuilder||t.MozBlobBuilder||t.MSBlobBuilder;var o=/^data:((.*?)(;charset=.*?)?)(;base64)?,/;var s=(i||n)&&t.atob&&t.ArrayBuffer&&t.Uint8Array&&function(e){var t,r,s,l,f,c,u,h,v;t=e.match(o);if(!t){throw new Error("invalid data URI")}r=t[2]?t[1]:"text/plain"+(t[3]||";charset=US-ASCII");s=!!t[4];l=e.slice(t[0].length);if(s){f=atob(l)}else{f=decodeURIComponent(l)}c=new ArrayBuffer(f.length);u=new Uint8Array(c);for(h=0;h<f.length;h+=1){u[h]=f.charCodeAt(h)}if(i){return new Blob([a?u:c],{type:r})}v=new n;v.append(c);return v.getBlob(r)};if(t.HTMLCanvasElement&&!r.toBlob){if(r.mozGetAsFile){r.toBlob=function(e,t,i){var a=this;setTimeout((function(){if(i&&r.toDataURL&&s){e(s(a.toDataURL(t,i)))}else{e(a.mozGetAsFile("blob",t))}}))}}else if(r.toDataURL&&s){r.toBlob=function(e,t,r){var i=this;setTimeout((function(){e(s(i.toDataURL(t,r)))}))}}}if(babelHelpers["typeof"](e)==="object"&&e.exports){e.exports=s}else{t.dataURLtoBlob=s}})(window)}));var a=function(e){if(typeof Blob==="undefined"){return false}return e instanceof Blob||Object.prototype.toString.call(e)==="[object Blob]"};var n={strict:true,checkOrientation:true,maxWidth:Infinity,maxHeight:Infinity,minWidth:0,minHeight:0,width:undefined,height:undefined,quality:.8,mimeType:"auto",convertSize:5e6,beforeDraw:null,drew:null,success:null,error:null};var o=typeof window!=="undefined";var s=o?window:{};var l=Array.prototype.slice;function f(e){return Array.from?Array.from(e):l.call(e)}var c=/^image\/.+$/;function u(e){return c.test(e)}function h(e){var t=u(e)?e.substr(6):"";if(t==="jpeg"){t="jpg"}return".".concat(t)}var v=String.fromCharCode;function b(e,t,r){var i="";var a;r+=t;for(a=t;a<r;a+=1){i+=v(e.getUint8(a))}return i}var d=s.btoa;function p(e,t){var r=[];var i=8192;var a=new Uint8Array(e);while(a.length>0){r.push(v.apply(null,f(a.subarray(0,i))));a=a.subarray(i)}return"data:".concat(t,";base64,").concat(d(r.join("")))}function m(e){var t=new DataView(e);var r;try{var i;var a;var n;if(t.getUint8(0)===255&&t.getUint8(1)===216){var o=t.byteLength;var s=2;while(s+1<o){if(t.getUint8(s)===255&&t.getUint8(s+1)===225){a=s;break}s+=1}}if(a){var l=a+4;var f=a+10;if(b(t,l,4)==="Exif"){var c=t.getUint16(f);i=c===18761;if(i||c===19789){if(t.getUint16(f+2,i)===42){var u=t.getUint32(f+4,i);if(u>=8){n=f+u}}}}}if(n){var h=t.getUint16(n,i);var v;var d;for(d=0;d<h;d+=1){v=n+d*12+2;if(t.getUint16(v,i)===274){v+=8;r=t.getUint16(v,i);t.setUint16(v,1,i);break}}}}catch(e){r=1}return r}function g(e){var t=0;var r=1;var i=1;switch(e){case 2:r=-1;break;case 3:t=-180;break;case 4:i=-1;break;case 5:t=90;i=-1;break;case 6:t=90;break;case 7:t=90;r=-1;break;case 8:t=-90;break;default:}return{rotate:t,scaleX:r,scaleY:i}}var y=/\.\d*(?:0|9){12}\d*$/;function w(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1e11;return y.test(e)?Math.round(e*t)/t:e}function O(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);if(t)i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}));r.push.apply(r,i)}return r}function j(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};if(t%2){O(Object(r),true).forEach((function(t){babelHelpers.defineProperty(e,t,r[t])}))}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{O(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}}return e}var B=s.ArrayBuffer,U=s.FileReader;var k=s.URL||s.webkitURL;var x=/\.\w+$/;var P=s.Compressor;var T=function(){function e(t,r){babelHelpers.classCallCheck(this,e);this.file=t;this.image=new Image;this.options=j(j({},n),r);this.aborted=false;this.result=null;this.init()}babelHelpers.createClass(e,[{key:"init",value:function e(){var t=this;var r=this.file,i=this.options;if(!a(r)){this.fail(new Error("The first argument must be a File or Blob object."));return}var n=r.type;if(!u(n)){this.fail(new Error("The first argument must be an image File or Blob object."));return}if(!k||!U){this.fail(new Error("The current browser does not support image compression."));return}if(!B){i.checkOrientation=false}if(k&&!i.checkOrientation){this.load({url:k.createObjectURL(r)})}else{var o=new U;var s=i.checkOrientation&&n==="image/jpeg";this.reader=o;o.onload=function(e){var i=e.target;var a=i.result;var o={};if(s){var l=m(a);if(l>1||!k){o.url=p(a,n);if(l>1){Object.assign(o,g(l))}}else{o.url=k.createObjectURL(r)}}else{o.url=a}t.load(o)};o.onabort=function(){t.fail(new Error("Aborted to read the image with FileReader."))};o.onerror=function(){t.fail(new Error("Failed to read the image with FileReader."))};o.onloadend=function(){t.reader=null};if(s){o.readAsArrayBuffer(r)}else{o.readAsDataURL(r)}}}},{key:"load",value:function e(t){var r=this;var i=this.file,a=this.image;a.onload=function(){r.draw(j(j({},t),{},{naturalWidth:a.naturalWidth,naturalHeight:a.naturalHeight}))};a.onabort=function(){r.fail(new Error("Aborted to load the image."))};a.onerror=function(){r.fail(new Error("Failed to load the image."))};a.alt=i.name;a.src=t.url}},{key:"draw",value:function e(t){var r=this;var a=t.naturalWidth,n=t.naturalHeight,o=t.rotate,s=o===void 0?0:o,l=t.scaleX,f=l===void 0?1:l,c=t.scaleY,h=c===void 0?1:c;var v=this.file,b=this.image,d=this.options;var p=document.createElement("canvas");var m=p.getContext("2d");var g=a/n;var y=Math.abs(s)%180===90;var O=Math.max(d.maxWidth,0)||Infinity;var j=Math.max(d.maxHeight,0)||Infinity;var B=Math.max(d.minWidth,0)||0;var U=Math.max(d.minHeight,0)||0;var k=Math.max(d.width,0)||a;var x=Math.max(d.height,0)||n;if(y){var P=[j,O];O=P[0];j=P[1];var T=[U,B];B=T[0];U=T[1];var H=[x,k];k=H[0];x=H[1]}if(O<Infinity&&j<Infinity){if(j*g>O){j=O/g}else{O=j*g}}else if(O<Infinity){j=O/g}else if(j<Infinity){O=j*g}if(B>0&&U>0){if(U*g>B){U=B/g}else{B=U*g}}else if(B>0){U=B/g}else if(U>0){B=U*g}if(x*g>k){x=k/g}else{k=x*g}k=Math.floor(w(Math.min(Math.max(k,B),O)));x=Math.floor(w(Math.min(Math.max(x,U),j)));var E=-k/2;var M=-x/2;var D=k;var A=x;if(y){var C=[x,k];k=C[0];x=C[1]}p.width=k;p.height=x;if(!u(d.mimeType)){d.mimeType=v.type}var L="transparent";if(v.size>d.convertSize&&d.mimeType==="image/png"){L="#fff";d.mimeType="image/jpeg"}m.fillStyle=L;m.fillRect(0,0,k,x);if(d.beforeDraw){d.beforeDraw.call(this,m,p)}if(this.aborted){return}m.save();m.translate(k/2,x/2);m.rotate(s*Math.PI/180);m.scale(f,h);m.drawImage(b,E,M,D,A);m.restore();if(d.drew){d.drew.call(this,m,p)}if(this.aborted){return}var R=function e(t){if(!r.aborted){r.done({naturalWidth:a,naturalHeight:n,result:t})}};if(p.toBlob){p.toBlob(R,d.mimeType,d.quality)}else{R(i(p.toDataURL(d.mimeType,d.quality)))}}},{key:"done",value:function e(t){var r=t.naturalWidth,i=t.naturalHeight,a=t.result;var n=this.file,o=this.image,s=this.options;if(k&&!s.checkOrientation){k.revokeObjectURL(o.src)}if(a){if(s.strict&&a.size>n.size&&s.mimeType===n.type&&!(s.width>r||s.height>i||s.minWidth>r||s.minHeight>i)){a=n}else{var l=new Date;a.lastModified=l.getTime();a.lastModifiedDate=l;a.name=n.name;if(a.name&&a.type!==n.type){a.name=a.name.replace(x,h(a.type))}}}else{a=n}this.result=a;if(s.success){s.success.call(this,a)}}},{key:"fail",value:function e(t){var r=this.options;if(r.error){r.error.call(this,t)}else{throw t}}},{key:"abort",value:function e(){if(!this.aborted){this.aborted=true;if(this.reader){this.reader.abort()}else if(!this.image.complete){this.image.onload=null;this.image.onabort()}else{this.fail(new Error("The compression process has been aborted."))}}}}],[{key:"noConflict",value:function t(){window.Compressor=P;return e}},{key:"setDefaults",value:function e(t){Object.assign(n,t)}}]);return e}();var H=["width","height","maxWidth","maxHeight","minWidth","minHeight"];function E(e){if(!t.Type.isString(e)){return Promise.resolve(e)}return new Promise((function(r,i){try{var a=t.ajax.xhr();a.open("GET",e);a.responseType="blob";a.onerror=function(){i(new Error("Network error."))};a.onload=function(){if(a.status===200){r(a.response)}else{i(new Error("Loading error: ".concat(a.statusText)))}};a.send()}catch(e){i(e.message)}}))}function M(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);if(t)i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}));r.push.apply(r,i)}return r}function D(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};if(t%2){M(Object(r),true).forEach((function(t){babelHelpers.defineProperty(e,t,r[t])}))}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{M(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}}return e}var A=function(){function e(r){var i=this;var a=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};babelHelpers.classCallCheck(this,e);this.file=r;this.options=D({quality:.8},a);if(this.options.retina){H.forEach((function(e){if(t.Type.isNumber(i.options[e])){i.options[e]*=2}}))}}babelHelpers.createClass(e,[{key:"compress",value:function e(){var t=this;return new Promise((function(e,r){void new T(t.file,D(D({},t.options),{success:e,error:r}))}))}}],[{key:"compress",value:function r(i){var a=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return E(i).then((function(r){if(t.Type.isStringFilled(r.type)){if(r.type.includes("gif")||r.type.includes("png")&&r.size<e.maxOriginalPngSize){return r}}var i=new e(r,a);return i.compress()}))}}]);return e}();babelHelpers.defineProperty(A,"maxOriginalPngSize",5*1024*1024);e.ImageCompressor=A})(this.BX.Landing=this.BX.Landing||{},BX);
//# sourceMappingURL=imagecompressor.bundle.map.js